<?php
//
// +------------------------------------------------------------------------+
// | Gecko Framework                                                        |
// +------------------------------------------------------------------------+
//
require_once( 'Gecko/Security.php' );

/**
 * Checks security on a controller
 *
 * @package Gecko
 * @author Christopher Valderrama <gatorv@gmail.com>
 * @copyright Copyright (c) 2007-2008
 * @version $Id$
 * @access public
 */
class Gecko_Security_Controller extends Gecko_Security {
	/**
	 * The current controller
	 *
	 * @var string
	 */
	private $controller;

	/**
	 * Creates a Security object for a controller
	 *
	 * @param Gecko_Controller $controller
	 */
	public function __construct( Gecko_Controller $controller ) {
		$controller = $controller->getControllerName();
		$action = $controller->getAction();

		parent::__construct( $controller, $action );
	}

	/**
	 * Return the controller
	 *
	 * @return string
	 */
	public function getController() {
		return $this->controller;
	}

	/**
	 * Sets the active controller
	 *
	 * @param Gecko_Controller $controller The new controller
	 */
	public function setController(Gecko_Controller $controller) {
		$this->controller = $controller->getControllerName();
		$this->setResource($controller->getControllerName());
	}
}